<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            position: absolute;
            width: 100px;
            height: 100px;
            left: 0;
            top: 50px;
            background-color: red;
        }
    </style>
    <script src="js/animate6.js"></script>
</head>

<body>
    <button>点我啊</button>
    <div class="box"></div>

    <script>
        // 需求：点一下按钮，盒子转一圈自己回来
        // 先到left：600，再到top：400，再到left：0，再到top：50

        let box = document.querySelector('.box');

        document.querySelector('button').onclick = function () {
            // animate(box, 600, 'left');
            // animate(box, 400, 'top');
            // 顺序调用不行

            animate(box, 600, 'left', function () {
                animate(box, 400, 'top', function () {
                    animate(box, 0, 'left', function () {
                        animate(box, 50, 'top')
                    });
                });
            });
        }

    </script>
</body>

</html>